home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / TUTORIAL / 1307B.ZIP / PRINTFLE.MOD < prev    next >
Text File  |  1989-01-18  |  1KB  |  55 lines

  1.                                          (* Chapter 8 - Program 5 *)
  2. MODULE PrintFle;
  3.  
  4. FROM FileSystem IMPORT Lookup, Close, File, Response, ReadChar,
  5.                        WriteChar;
  6. FROM InOut      IMPORT Write, WriteString, ReadString, WriteLn;
  7.  
  8. VAR  NameOfFile : ARRAY[1..15] OF CHAR;
  9.      InFile     : File;
  10.      OutFile    : File;
  11.      CapFile    : File;
  12.      PrtFile    : File;
  13.      Character  : CHAR;
  14.  
  15. BEGIN
  16.    REPEAT                  (* repeat until a good filename is found *)
  17.       WriteLn;
  18.       WriteString("Enter name of file to display,");
  19.       WriteString(" store, and print ---> ");
  20.       ReadString(NameOfFile);
  21.       Lookup(InFile,NameOfFile,FALSE);
  22.    UNTIL InFile.res = done;                  (* good filename found *)
  23.  
  24.    Lookup(OutFile,"ANYNAME.TXT",TRUE);
  25.    Lookup(CapFile,"CAPSONLY.TXT",TRUE);
  26.    Lookup(PrtFile,"PRN",TRUE);
  27.  
  28.    WriteLn;
  29.    REPEAT       (* character read/display loop - quit at InFile.eof *)
  30.       ReadChar(InFile,Character);
  31.       IF NOT InFile.eof THEN
  32.          Write(Character);
  33.          WriteChar(OutFile,Character);
  34.          WriteChar(CapFile,CAP(Character));
  35.          WriteChar(PrtFile,Character);
  36.       END;
  37.    UNTIL InFile.eof;                      (* quit when eof is found *)
  38.    Close(InFile);
  39.    Close(OutFile);
  40.    Close(CapFile);
  41.    Close(PrtFile);
  42.  
  43. END PrintFle.
  44.  
  45.  
  46.  
  47.  
  48. (* Result of execution
  49.  
  50. (The selected file is copied to two other files, to the monitor,
  51.  and to the printer.)
  52.  
  53. *)
  54.  
  55.